<div class="breadcrumbs" id="breadcrumbs">
    <ul class="breadcrumb">
        <li><i class="icon-picture home-icon"></i><a href="javascript:;">系统工具</a></li>
        <li>文件上传</li>
    </ul><!-- .breadcrumb -->
</div>
<div class="page-content">
    <div class="row">
        <ul class="col-xs-12">
            <li class="clearfix" style="height: 30px; padding-left: 12px;">
                <div id="ifh_pic_tool_upload_tip">点击以下按钮选择文件(png/jpeg/jpg/gif/swf/css/js/xml/pdf/doc/zip/rar/mp3/arm/apk/mp4/ico)上传(图片文件必须小于：1Mb，其他文件必须小于：8Mb)</div>
            </li>
            <li class="clearfix">
                <div class="col-xs-2"><input id="btn_ifh_pic_tool_upload" type="file" /></div>
                <div class="col-xs-10" id="ifh_pic_tool_upload_url"></div>
            </li>
            <li class="clearfix">
                <div id="ifh_pic_upload_queue"></div>
            </li>
        </ul>
    </div><!-- /.row -->
</div><!-- /.page-content -->
<script>
    $(function() {
        var pageObject = {
            _timer: null,
            _tipid: '#ifh_pic_tool_upload_tip',
            _urlid: '#ifh_pic_tool_upload_url',
            _defaultTip: '点击以下按钮选择文件(png/jpeg/jpg/gif/swf/css/js/xml/pdf/doc/zip/rar/mp3/arm/apk/mp4/ico)上传',

            /**
             * 显示提示信息
             */
            tip: function(msg) {
                if (pageObject._timer != null) {
                    clearTimeout(pageObject._timer);
                }
                $(pageObject._tipid).text(msg);
                pageObject._timer = setTimeout(function(){$(pageObject._tipid).text(pageObject._defaultTip);}, 5000);
            },

            /**
             * 设置URL
             */
            setUrl: function(url) {
                $(pageObject._urlid).append('<div>'+url+'</div>');
            }
        };

        var uploader = {};
        uploader.bindBtns = function() {
            var opts = {
                height        : "26px",
                width         : "64px",
                buttonText    : '文件上传',
                queueID       : 'ifh_pic_upload_queue',
                // 是否阻止flash缓存(default:true)
                prevent_swf_caching: false,
                button_image_url: "",
                fileSizeLimit : '8MB',
                fileTypeExts  : '*.jpg;*.jpeg;*.png;*.gif;*.css;*.js;*.swf;*.xml;*.pdf;*.docx;*.doc;*.ppt;*.pptx;*.xls;*.xlsx;*.zip;*.rar;*.mp3;*.arm;*.apk;*.mp4;*.ico;',
                swf           : GBL.assetsDomain + '/uploadify/uploadify.swf',
                uploader      : GBL.domain + '/pic/tool/upload',
                onUploadStart : function(file) {
                    pageObject.tip('文件开始上传，请勿重复操作。');
                },
                onUploadSuccess : function(file, data, response) {
                    var json = $.parseJSON(data);
                    if (json && json.errno == "0") {
                        pageObject.tip('文件上传成功，可以复制以下链接使用。');
                        pageObject.setUrl(json.data.file);
                    } else {
                        pageObject.tip(json.msg);
                    }
                }
            };
            $("#btn_ifh_pic_tool_upload").uploadify(opts);
        };

        // 已经加载过
        if (typeof swfobject == "object") {
            uploader.bindBtns();
        }

        IFH.loadResource('/uploadify/uploadify.css', 'css');
        IFH.loadResource('/uploadify/jquery.uploadify.js?v='+Math.random(), 'js', uploader.bindBtns);
    });
</script>